home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / ASSEMBLE / 1586.ZIP / ASM-SRC.ARC / INSTTABL.C < prev    next >
Text File  |  1988-09-05  |  26KB  |  813 lines

  1. /***********************************************************************
  2.  *
  3.  *        INSTTABLE.C
  4.  *        Instruction Table for 68000 Assembler
  5.  *
  6.  * Description: This file contains two kinds of data structure declara-
  7.  *        tions: "flavor lists" and the instruction table. First
  8.  *        in the file are "flavor lists," one for each different
  9.  *        instruction. Then comes the instruction table, which
  10.  *        contains the mnemonics of the various instructions, a
  11.  *        pointer to the flavor list for each instruction, and
  12.  *        other data. Finally, the variable tableSize is
  13.  *        initialized to contain the number of instructions in
  14.  *        the table. 
  15.  *
  16.  *      Author: Paul McKee
  17.  *        ECE492    North Carolina State University
  18.  *
  19.  *        Date:    12/13/86
  20.  *
  21.  ************************************************************************/
  22.  
  23. /*********************************************************************
  24.  
  25.           HOW THE INSTRUCTION TABLE AND FLAVOR LISTS ARE USED
  26.  
  27.      The procedure which instLookup() and assemble() use to look up
  28. and verify an instruction (or directive) is as follows. Once the
  29. mnemonic of the instruction has been parsed and stripped of its size
  30. code and trailing spaces, the instLookup() does a binary search on the
  31. instruction table to determine if the mnemonic is present. If it is
  32. not found, then the INV_OPCODE error results. If the mnemonic is
  33. found, then assemble() examines the field parseFlag for that entry.
  34. This flag is TRUE if the mnemonic represents a normal instruction that
  35. can be parsed by assemble(); it is FALSE if the instruction's operands
  36. have an unusual format (as is the case for MOVEM and DC). 
  37.  
  38.       If the parseFlag is TRUE, then assemble will parse the
  39. instruction's operands, check them for validity, and then pass the
  40. data to the proper routine which will build the instruction. To do
  41. this it uses the pointer in the instruction table to the instruction's
  42. "flavor list" and scans through the list until it finds an particular
  43. "flavor" of the instruction which matches the addressing mode(s)
  44. specified.  If it finds such a flavor, it checks the instruction's
  45. size code and passes the instruction mask for the appropriate size 
  46. (there are three masks for each flavor) to the building routine
  47. through a pointer in the flavor list for that flavor. 
  48.  
  49. *********************************************************************/
  50.  
  51.  
  52. #include <stdio.h>
  53. #include "asm.h"
  54.  
  55. /* Definitions of addressing mode masks for various classes of references */
  56.  
  57. #define Data    (DnDirect | AnInd | AnIndPost | AnIndPre | AnIndDisp \
  58.          | AnIndIndex | AbsShort | AbsLong | PCDisp | PCIndex \
  59.          | Immediate)
  60.  
  61. #define Memory    (AnInd | AnIndPost | AnIndPre | AnIndDisp | AnIndIndex \
  62.          | AbsShort | AbsLong | PCDisp | PCIndex | Immediate)
  63.  
  64. #define Control    (AnInd | AnIndDisp | AnIndIndex | AbsShort | AbsLong | PCDisp \
  65.          | PCIndex)
  66.  
  67. #define Alter    (DnDirect | AnDirect | AnInd | AnIndPost | AnIndPre \
  68.          | AnIndDisp | AnIndIndex | AbsShort | AbsLong)
  69.  
  70. #define All    (Data | Memory | Control | Alter)
  71. #define DataAlt    (Data & Alter)
  72. #define MemAlt    (Memory & Alter)
  73. #define Absolute (AbsLong | AbsShort)
  74. #define GenReg    (DnDirect | AnDirect)
  75.  
  76.  
  77. /* Define size code masks for instructions that allow more than one size */
  78.  
  79. #define BW    (BYTE | WORD)
  80. #define WL    (WORD | LONG)
  81. #define BWL    (BYTE | WORD | LONG)
  82. #define BL    (BYTE | LONG)
  83.  
  84.  
  85. /* Define the "flavor lists" for each different instruction */
  86.  
  87. flavor abcdfl[] = {
  88.     { DnDirect, DnDirect, BYTE, twoReg, 0xC100, 0xC100, 0 },
  89.     { AnIndPre, AnIndPre, BYTE, twoReg, 0xC108, 0xC108, 0 }
  90.        };
  91.  
  92. flavor addfl[] = {
  93.     { Immediate, DataAlt, BWL, immedInst, 0x0600, 0x0640, 0x0680 },
  94.     { Immediate, AnDirect, WL, quickMath, 0, 0x5040, 0x5080 },
  95.     { All, DnDirect, BWL, arithReg, 0xD000, 0xD040, 0xD080 },
  96.     { DnDirect, MemAlt, BWL, arithAddr, 0xD100, 0xD140, 0xD180 },
  97.     { All, AnDirect, WL, arithReg, 0, 0xD0C0, 0xD1C0 },
  98.        };
  99.  
  100. flavor addafl[] = {
  101.     { All, AnDirect, WL, arithReg, 0, 0xD0C0, 0xD1C0 },
  102.        };
  103.  
  104. flavor addifl[] = {
  105.     { Immediate, DataAlt, BWL, immedInst, 0x0600, 0x0640, 0x0680 }
  106.        };
  107.  
  108. flavor addqfl[] = {
  109.     { Immediate, DataAlt, BWL, quickMath, 0x5000, 0x5040, 0x5080 },
  110.     { Immediate, AnDirect, WL, quickMath, 0, 0x5040, 0x5080 }
  111.        };
  112.  
  113. flavor addxfl[] = {
  114.     { DnDirect, DnDirect, BWL, twoReg, 0xD100, 0xD140, 0xD180 },
  115.     { AnIndPre, AnIndPre, BWL, twoReg, 0xD108, 0xD148, 0xD188 }
  116.        };
  117.  
  118. flavor andfl[] = {
  119.     { Data, DnDirect, BWL, arithReg, 0xC000, 0xC040, 0xC080 },
  120.     { DnDirect, MemAlt, BWL, arithAddr, 0xC100, 0xC140, 0xC180 },
  121.     { Immediate, DataAlt, BWL, immedInst, 0x0200, 0x0240, 0x0280 }
  122.        };
  123.  
  124. flavor andifl[] = {
  125.     { Immediate, DataAlt, BWL, immedInst, 0x0200, 0x0240, 0x0280 },
  126.     { Immediate, CCRDirect, BYTE, immedToCCR, 0x023C, 0x023C, 0 },
  127.     { Immediate, SRDirect, WORD, immedWord, 0, 0x027C, 0 }
  128.        };
  129.  
  130. flavor aslfl[] = {
  131.     { MemAlt, 0, WORD, oneOp, 0, 0xE1C0, 0 },
  132.     { DnDirect, DnDirect, BWL, shiftReg, 0xE120, 0xE160, 0xE1A0 },
  133.     { Immediate, DnDirect, BWL, shiftReg, 0xE100, 0xE140, 0xE180 }
  134.        };
  135.  
  136. flavor asrfl[] = {
  137.     { MemAlt, 0, WORD, oneOp, 0, 0xE0C0, 0 },
  138.     { DnDirect, DnDirect, BWL, shiftReg, 0xE020, 0xE060, 0xE0A0 },
  139.     { Immediate, DnDirect, BWL, shiftReg, 0xE000, 0xE040, 0xE080 }
  140.        };
  141.  
  142. flavor bccfl[] = {
  143.     { Absolute, 0, SHORT | LONG, branch, 0x6400, 0x6400, 0x6400 }
  144.        };
  145.  
  146. flavor bchgfl[] = {
  147.     { DnDirect, MemAlt, BYTE, arithAddr, 0x0140, 0x0140, 0 },
  148.     { DnDirect, DnDirect, LONG, arithAddr, 0, 0x0140, 0x0140 },
  149.     { Immediate, MemAlt, BYTE, staticBit, 0x0840, 0x0840, 0 },
  150.     { Immediate, DnDirect, LONG, staticBit, 0, 0x0840, 0x0840 }
  151.        };
  152.  
  153. flavor bclrfl[] = {
  154.     { DnDirect, MemAlt, BYTE, arithAddr, 0x0180, 0x0180, 0 },
  155.     { DnDirect, DnDirect, LONG, arithAddr, 0, 0x0180, 0x0180 },
  156.     { Immediate, MemAlt, BYTE, staticBit, 0x0880, 0x0880, 0 },
  157.     { Immediate, DnDirect, LONG, staticBit, 0, 0x0880, 0x0880 }
  158.        };
  159.  
  160. flavor bcsfl[] = {
  161.     { Absolute, 0, SHORT | LONG, branch, 0x6500, 0x6500, 0x6500 }
  162.        };
  163.  
  164. flavor beqfl[] = {
  165.     { Absolute, 0, SHORT | LONG, branch, 0x6700, 0x6700, 0x6700 }
  166.        };
  167.  
  168. flavor bgefl[] = {
  169.     { Absolute, 0, SHORT | LONG, branch, 0x6C00, 0x6C00, 0x6C00 }
  170.        };
  171.  
  172. flavor bgtfl[] = {
  173.     { Absolute, 0, SHORT | LONG, branch, 0x6E00, 0x6E00, 0x6E00 }
  174.        };
  175.  
  176. flavor bhifl[] = {
  177.     { Absolute, 0, SHORT | LONG, branch, 0x6200, 0x6200, 0x6200 }
  178.        };
  179.  
  180. flavor bhsfl[] = {
  181.     { Absolute, 0, SHORT | LONG, branch, 0x6400, 0x6400, 0x6400 }
  182.        };
  183.  
  184. flavor blefl[] = {
  185.     { Absolute, 0, SHORT | LONG, branch, 0x6f00, 0x6F00, 0x6F00 }
  186.        };
  187.  
  188. flavor blofl[] = {
  189.     { Absolute, 0, SHORT | LONG, branch, 0x6500, 0x6500, 0x6500 }
  190.        };
  191.  
  192. flavor blsfl[] = {
  193.     { Absolute, 0, SHORT | LONG, branch, 0x6300, 0x6300, 0x6300 }
  194.        };
  195.  
  196. flavor bltfl[] = {
  197.     { Absolute, 0, SHORT | LONG, branch, 0x6d00, 0x6D00, 0x6D00 }
  198.        };
  199.  
  200. flavor bmifl[] = {
  201.     { Absolute, 0, SHORT | LONG, branch, 0x6b00, 0x6B00, 0x6B00 }
  202.        };
  203.  
  204. flavor bnefl[] = {
  205.     { Absolute, 0, SHORT | LONG, branch, 0x6600, 0x6600, 0x6600 }
  206.        };
  207.  
  208. flavor bplfl[] = {
  209.     { Absolute, 0, SHORT | LONG, branch, 0x6a00, 0x6A00, 0x6A00 }
  210.        };
  211.  
  212. flavor brafl[] = {
  213.     { Absolute, 0, SHORT | LONG, branch, 0x6000, 0x6000, 0x6000 }
  214.        };
  215.  
  216. flavor bsetfl[] = {
  217.     { DnDirect, MemAlt, BYTE, arithAddr, 0x01C0, 0x01C0, 0 },
  218.     { DnDirect, DnDirect, LONG, arithAddr, 0, 0x01C0, 0x01C0 },
  219.     { Immediate, MemAlt, BYTE, staticBit, 0x08C0, 0x08C0, 0 },
  220.     { Immediate, DnDirect, LONG, staticBit, 0, 0x08C0, 0x08C0 }
  221.        };
  222.  
  223. flavor bsrfl[] = {
  224.     { Absolute, 0, SHORT | LONG, branch, 0x6100, 0x6100, 0x6100 }
  225.        };
  226.  
  227. flavor btstfl[] = {
  228.     { DnDirect, Memory, BYTE, arithAddr, 0x0100, 0x0100, 0 },
  229.     { DnDirect, DnDirect, LONG, arithAddr, 0, 0x0100, 0x0100 },
  230.     { Immediate, Memory, BYTE, staticBit, 0x0800, 0x0800, 0 },
  231.     { Immediate, DnDirect, LONG, staticBit, 0, 0x0800, 0x0800 }
  232.        };
  233.  
  234. flavor bvcfl[] = {
  235.     { Absolute, 0, SHORT | LONG, branch, 0x6800, 0x6800, 0x6800 }
  236.        };
  237.  
  238. flavor bvsfl[] = {
  239.     { Absolute, 0, SHORT | LONG, branch, 0x6900, 0x6900, 0x6900 }
  240.        };
  241.  
  242. flavor chkfl[] = {
  243.     { Data, DnDirect, WORD, arithReg, 0, 0x4180, 0 }
  244.        };
  245.  
  246. flavor clrfl[] = {
  247.     { DataAlt, 0, BWL, oneOp, 0x4200, 0x4240, 0x4280 }
  248.        };
  249.  
  250. flavor cmpfl[] = {
  251.     { All, DnDirect, BWL, arithReg, 0xB000, 0xB040, 0xB080 },
  252.     { All, AnDirect, WL, arithReg, 0, 0xB0C0, 0xB1C0 },
  253.     { Immediate, DataAlt, BWL, immedInst, 0x0C00, 0x0C40, 0x0C80 }
  254.        };
  255.  
  256. flavor cmpafl[] = {
  257.     { All, AnDirect, WL, arithReg, 0, 0xB0C0, 0xB1C0 }
  258.        };
  259.  
  260. flavor cmpifl[] = {
  261.     { Immediate, DataAlt, BWL, immedInst, 0x0C00, 0x0C40, 0x0C80 }
  262.        };
  263.  
  264. flavor cmpmfl[] = {
  265.     { AnIndPost, AnIndPost, BWL, twoReg, 0xB108, 0xB148, 0xB188 }
  266.        };
  267.  
  268. flavor dbccfl[] = {
  269.     { DnDirect, Absolute, WORD, dbcc, 0, 0x54C8, 0 }
  270.        };
  271.  
  272. flavor dbcsfl[] = {
  273.     { DnDirect, Absolute, WORD, dbcc, 0, 0x55C8, 0 }
  274.        };
  275.  
  276. flavor dbeqfl[] = {
  277.     { DnDirect, Absolute, WORD, dbcc, 0, 0x57C8, 0 }
  278.        };
  279.  
  280. flavor dbffl[] = {
  281.     { DnDirect, Absolute, WORD, dbcc, 0, 0x51C8, 0 }
  282.        };
  283.  
  284. flavor dbgefl[] = {
  285.     { DnDirect, Absolute, WORD, dbcc, 0, 0x5CC8, 0 }
  286.        };
  287.  
  288. flavor dbgtfl[] = {
  289.     { DnDirect, Absolute, WORD, dbcc, 0, 0x5EC8, 0 }
  290.        };
  291.  
  292. flavor dbhifl[] = {
  293.     { DnDirect, Absolute, WORD, dbcc, 0, 0x52C8, 0 }
  294.        };
  295.  
  296. flavor dbhsfl[] = {
  297.     { DnDirect, Absolute, WORD, dbcc, 0, 0x54C8, 0 }
  298.        };
  299.  
  300. flavor dblefl[] = {
  301.     { DnDirect, Absolute, WORD, dbcc, 0, 0x5FC8, 0 }
  302.        };
  303.  
  304. flavor dblofl[] = {
  305.     { DnDirect, Absolute, WORD, dbcc, 0, 0x55C8, 0 }
  306.        };
  307.  
  308. flavor dblsfl[] = {
  309.     { DnDirect, Absolute, WORD, dbcc, 0, 0x53C8, 0 }
  310.        };
  311.  
  312. flavor dbltfl[] = {
  313.     { DnDirect, Absolute, WORD, dbcc, 0, 0x5DC8, 0 }
  314.        };
  315.  
  316. flavor dbmifl[] = {
  317.     { DnDirect, Absolute, WORD, dbcc, 0, 0x5BC8, 0 }
  318.        };
  319.  
  320. flavor dbnefl[] = {
  321.     { DnDirect, Absolute, WORD, dbcc, 0, 0x56C8, 0 }
  322.        };
  323.  
  324. flavor dbplfl[] = {
  325.     { DnDirect, Absolute, WORD, dbcc, 0, 0x5AC8, 0 }
  326.        };
  327.  
  328. flavor dbrafl[] = {
  329.     { DnDirect, Absolute, WORD, dbcc, 0, 0x51C8, 0 }
  330.        };
  331.  
  332. flavor dbtfl[] = {
  333.     { DnDirect, Absolute, WORD, dbcc, 0, 0x50C8, 0 }
  334.        };
  335.  
  336. flavor dbvcfl[] = {
  337.     { DnDirect, Absolute, WORD, dbcc, 0, 0x58C8, 0 }
  338.        };
  339.  
  340. flavor dbvsfl[] = {
  341.     { DnDirect, Absolute, WORD, dbcc, 0, 0x59C8, 0 }
  342.        };
  343.  
  344. flavor divsfl[] = {
  345.     { Data, DnDirect, WORD, arithReg, 0, 0x81C0, 0 }
  346.        };
  347.  
  348. flavor divufl[] = {
  349.     { Data, DnDirect, WORD, arithReg, 0, 0x80C0, 0 }
  350.        };
  351.  
  352. flavor eorfl[] = {
  353.     { DnDirect, DataAlt, BWL, arithAddr, 0xB100, 0xB140, 0xB180 },
  354.     { Immediate, DataAlt, BWL, immedInst, 0x0A00, 0x0A40, 0x0A80 }
  355.        };
  356.  
  357. flavor eorifl[] = {
  358.     { Immediate, DataAlt, BWL, immedInst, 0x0A00, 0x0A40, 0x0A80 },
  359.     { Immediate, CCRDirect, BYTE, immedToCCR, 0x0A3C, 0x0A3C, 0 },
  360.     { Immediate, SRDirect, WORD, immedWord, 0, 0x0A7C, 0 }
  361.        };
  362.  
  363. flavor exgfl[] = {
  364.     { DnDirect, DnDirect, LONG, exg, 0, 0xC140, 0xC140 },
  365.     { AnDirect, AnDirect, LONG, exg, 0, 0xC148, 0xC148 },
  366.     { GenReg, GenReg, LONG, exg, 0, 0xC188, 0xC188 }
  367.        };
  368.  
  369. flavor extfl[] = {
  370.     { DnDirect, 0, WL, oneReg, 0, 0x4880, 0x48C0 }
  371.        };
  372.  
  373. flavor illegalfl[] = {
  374.     { 0, 0, 0, zeroOp, 0, 0x4AFC, 0 }
  375.        };
  376.  
  377. flavor jmpfl[] = {
  378.     { Control, 0, 0, oneOp, 0, 0x4EC0, 0 }
  379.        };
  380.  
  381. flavor jsrfl[] = {
  382.     { Control, 0, 0, oneOp, 0, 0x4E80, 0 }
  383.        };
  384.  
  385. flavor leafl[] = {
  386.     { Control, AnDirect, LONG, arithReg, 0, 0x41C0, 0x41C0 }
  387.        };
  388.  
  389. flavor linkfl[] = {
  390.     { AnDirect, Immediate, 0, link, 0, 0x4E50, 0 }
  391.        };
  392.  
  393. flavor lslfl[] = {
  394.     { MemAlt, 0, WORD, oneOp, 0, 0xE3C0, 0 },
  395.     { DnDirect, DnDirect, BWL, shiftReg, 0xE128, 0xE168, 0xE1A8 },
  396.     { Immediate, DnDirect, BWL, shiftReg, 0xE108, 0xE148, 0xE188 }
  397.        };
  398.  
  399. flavor lsrfl[] = {
  400.     { MemAlt, 0, WORD, oneOp, 0, 0xE2C0, 0 },
  401.     { DnDirect, DnDirect, BWL, shiftReg, 0xE028, 0xE068, 0xE0A8 },
  402.     { Immediate, DnDirect, BWL, shiftReg, 0xE008, 0xE048, 0xE088 }
  403.        };
  404.  
  405. flavor movefl[] = {
  406.     { All, DataAlt, BWL, move, 0x1000, 0x3000, 0x2000 },
  407.     { All, AnDirect, WL, move, 0, 0x3000, 0x2000 },
  408.     { Data, CCRDirect, WORD, oneOp, 0, 0x44C0, 0 },
  409.     { Data, SRDirect, WORD, oneOp, 0, 0x46C0, 0 },
  410.     { CCRDirect, DataAlt, WORD, moveReg, 0, 0x42C0, 0 },
  411.     { SRDirect, DataAlt, WORD, moveReg, 0, 0x40C0, 0 },
  412.     { AnDirect, USPDirect, LONG, moveUSP, 0, 0x4E60, 0x4E60 },
  413.     { USPDirect, AnDirect, LONG, moveUSP, 0, 0x4E68, 0x4E68 }
  414.        };
  415.  
  416. flavor moveafl[] = {
  417.     { All, AnDirect, WL, move, 0, 0x3000, 0x2000 }
  418.        };
  419.  
  420. flavor movecfl[] = {
  421.     { SFCDirect | DFCDirect | USPDirect | VBRDirect,
  422.            GenReg, LONG, movec, 0, 0x4E7A, 0x4E7A },
  423.     { GenReg, SFCDirect | DFCDirect | USPDirect | VBRDirect,
  424.            LONG, movec, 0, 0x4E7B, 0x4E7B }
  425.        };
  426.  
  427. flavor movepfl[] = {
  428.     { DnDirect, AnIndDisp, WL, movep, 0, 0x0188, 0x01C8 },
  429.     { AnIndDisp, DnDirect, WL, movep, 0, 0x0108, 0x0148 },
  430.     { DnDirect, AnInd, WL, movep, 0, 0x0188, 0x01C8 },
  431.     { AnInd, DnDirect, WL, movep, 0, 0x0108, 0x0148 }
  432.        };
  433.  
  434. flavor moveqfl[] = {
  435.     { Immediate, DnDirect, LONG, moveq, 0, 0x7000, 0x7000 }
  436.        };
  437.  
  438. flavor movesfl[] = {
  439.     { GenReg, MemAlt, BWL, moves, 0x0E00, 0x0E40, 0x0E80 },
  440.     { MemAlt, GenReg, BWL, moves, 0x0E00, 0x0E40, 0x0E80 }
  441.        };
  442.  
  443. flavor mulsfl[] = {
  444.     { Data, DnDirect, WORD, arithReg, 0, 0xC1C0, 0 }
  445.        };
  446.  
  447. flavor mulufl[] = {
  448.     { Data, DnDirect, WORD, arithReg, 0, 0xC0C0, 0 }
  449.        };
  450.  
  451. flavor nbcdfl[] = {
  452.     { DataAlt, 0, BYTE, oneOp, 0x4800, 0x4800, 0 }
  453.        };
  454.  
  455. flavor negfl[] = {
  456.     { DataAlt, 0, BWL, oneOp, 0x4400, 0x4440, 0x4480 }
  457.        };
  458.  
  459. flavor negxfl[] = {
  460.     { DataAlt, 0, BWL, oneOp, 0x4000, 0x4040, 0x4080 }
  461.        };
  462.  
  463. flavor nopfl[] = {
  464.     { 0, 0, 0, zeroOp, 0, 0x4E71, 0 }
  465.        };
  466.  
  467. flavor notfl[] = {
  468.     { DataAlt, 0, BWL, oneOp, 0x4600, 0x4640, 0x4680 }
  469.        };
  470.  
  471. flavor orfl[] = {
  472.     { Data, DnDirect, BWL, arithReg, 0x8000, 0x8040, 0x8080 },
  473.     { DnDirect, MemAlt, BWL, arithAddr, 0x8100, 0x8140, 0x8180 },
  474.     { Immediate, DataAlt, BWL, immedInst, 0x0000, 0x0040, 0x0080 }
  475.        };
  476.  
  477. flavor orifl[] = {
  478.     { Immediate, DataAlt, BWL, immedInst, 0x0000, 0x0040, 0x0080 },
  479.     { Immediate, CCRDirect, BYTE, immedToCCR, 0x003C, 0x003C, 0 },
  480.     { Immediate, SRDirect, WORD, immedWord, 0, 0x007C, 0 }
  481.        };
  482.  
  483. flavor peafl[] = {
  484.     { Control, 0, LONG, oneOp, 0, 0x4840, 0x4840 }
  485.        };
  486.  
  487. flavor resetfl[] = {
  488.     { 0, 0, 0, zeroOp, 0, 0x4E70, 0 }
  489.        };
  490.  
  491. flavor rolfl[] = {
  492.     { MemAlt, 0, WORD, oneOp, 0, 0xE7C0, 0 },
  493.     { DnDirect, DnDirect, BWL, shiftReg, 0xE138, 0xE178, 0xE1B8 },
  494.     { Immediate, DnDirect, BWL, shiftReg, 0xE118, 0xE158, 0xE198 }
  495.        };
  496.  
  497. flavor rorfl[] = {
  498.     { MemAlt, 0, WORD, oneOp, 0, 0xE6C0, 0 },
  499.     { DnDirect, DnDirect, BWL, shiftReg, 0xE038, 0xE078, 0xE0B8 },
  500.     { Immediate, DnDirect, BWL, shiftReg, 0xE018, 0xE058, 0xE098 }
  501.        };
  502.  
  503. flavor roxlfl[] = {
  504.     { MemAlt, 0, WORD, oneOp, 0, 0xE5C0, 0 },
  505.     { DnDirect, DnDirect, BWL, shiftReg, 0xE130, 0xE170, 0xE1B0 },
  506.     { Immediate, DnDirect, BWL, shiftReg, 0xE110, 0xE150, 0xE190 }
  507.        };
  508.  
  509. flavor roxrfl[] = {
  510.     { MemAlt, 0, WORD, oneOp, 0, 0xE4C0, 0 },
  511.     { DnDirect, DnDirect, BWL, shiftReg, 0xE030, 0xE070, 0xE0B0 },
  512.     { Immediate, DnDirect, BWL, shiftReg, 0xE010, 0xE050, 0xE090 }
  513.        };
  514.  
  515. flavor rtdfl[] = {
  516.     { Immediate, 0, 0, immedWord, 0, 0x4E74, 0 }
  517.        };
  518.  
  519. flavor rtefl[] = {
  520.     { 0, 0, 0, zeroOp, 0, 0x4E73, 0 }
  521.        };
  522.  
  523. flavor rtrfl[] = {
  524.     { 0, 0, 0, zeroOp, 0, 0x4E77, 0 }
  525.        };
  526.  
  527. flavor rtsfl[] = {
  528.     { 0, 0, 0, zeroOp, 0, 0x4E75, 0 }
  529.        };
  530.  
  531. flavor sbcdfl[] = {
  532.     { DnDirect, DnDirect, BYTE, twoReg, 0x8100, 0x8100, 0 },
  533.     { AnIndPre, AnIndPre, BYTE, twoReg, 0x8108, 0x8108, 0 }
  534.        };
  535.  
  536. flavor sccfl[] = {
  537.     { DataAlt, 0, BYTE, scc, 0x54C0, 0x54C0, 0 }
  538.        };
  539.  
  540. flavor scsfl[] = {
  541.     { DataAlt, 0, BYTE, scc, 0x55C0, 0x55C0, 0 }
  542.        };
  543.  
  544. flavor seqfl[] = {
  545.     { DataAlt, 0, BYTE, scc, 0x57C0, 0x57C0, 0 }
  546.        };
  547.  
  548. flavor sffl[] = {
  549.     { DataAlt, 0, BYTE, scc, 0x51C0, 0x51C0, 0 }
  550.        };
  551.  
  552. flavor sgefl[] = {
  553.     { DataAlt, 0, BYTE, scc, 0x5CC0, 0x5CC0, 0 }
  554.        };
  555.  
  556. flavor sgtfl[] = {
  557.     { DataAlt, 0, BYTE, scc, 0x5EC0, 0x5EC0, 0 }
  558.        };
  559.  
  560. flavor shifl[] = {
  561.     { DataAlt, 0, BYTE, scc, 0x52C0, 0x52C0, 0 }
  562.        };
  563.  
  564. flavor shsfl[] = {
  565.     { DataAlt, 0, BYTE, scc, 0x54C0, 0x54C0, 0 }
  566.        };
  567.  
  568. flavor slefl[] = {
  569.     { DataAlt, 0, BYTE, scc, 0x5FC0, 0x5FC0, 0 }
  570.        };
  571.  
  572. flavor slofl[] = {
  573.     { DataAlt, 0, BYTE, scc, 0x55C0, 0x55C0, 0 }
  574.        };
  575.  
  576. flavor slsfl[] = {
  577.     { DataAlt, 0, BYTE, scc, 0x53C0, 0x53C0, 0 }
  578.        };
  579.  
  580. flavor sltfl[] = {
  581.     { DataAlt, 0, BYTE, scc, 0x5DC0, 0x5DC0, 0 }
  582.        };
  583.  
  584. flavor smifl[] = {
  585.     { DataAlt, 0, BYTE, scc, 0x5BC0, 0x5BC0, 0 }
  586.        };
  587.  
  588. flavor snefl[] = {
  589.     { DataAlt, 0, BYTE, scc, 0x56C0, 0x56C0, 0 }
  590.        };
  591.  
  592. flavor splfl[] = {
  593.     { DataAlt, 0, BYTE, scc, 0x5AC0, 0x5AC0, 0 }
  594.        };
  595.  
  596. flavor stfl[] = {
  597.     { DataAlt, 0, BYTE, scc, 0x50C0, 0x50C0, 0 }
  598.        };
  599.  
  600. flavor stopfl[] = {
  601.     { Immediate, 0, 0, immedWord, 0, 0x4E72, 0 }
  602.        };
  603.  
  604. flavor subfl[] = {
  605.     { Immediate, DataAlt, BWL, immedInst, 0x0400, 0x0440, 0x0480 },
  606.     { Immediate, AnDirect, WL, quickMath, 0, 0x5140, 0x5180 },
  607.     { All, DnDirect, BWL, arithReg, 0x9000, 0x9040, 0x9080 },
  608.     { DnDirect, MemAlt, BWL, arithAddr, 0x9100, 0x9140, 0x9180 },
  609.     { All, AnDirect, WL, arithReg, 0, 0x90C0, 0x91C0 },
  610.        };
  611.  
  612. flavor subafl[] = {
  613.     { All, AnDirect, WL, arithReg, 0, 0x90C0, 0x91C0 }
  614.        };
  615.  
  616. flavor subifl[] = {
  617.     { Immediate, DataAlt, BWL, immedInst, 0x0400, 0x0440, 0x0480 }
  618.        };
  619.  
  620. flavor subqfl[] = {
  621.     { Immediate, DataAlt, BWL, quickMath, 0x5100, 0x5140, 0x5180 },
  622.     { Immediate, AnDirect, WL, quickMath, 0, 0x5140, 0x5180 }
  623.        };
  624.  
  625. flavor subxfl[] = {
  626.     { DnDirect, DnDirect, BWL, twoReg, 0x9100, 0x9140, 0x9180 },
  627.     { AnIndPre, AnIndPre, BWL, twoReg, 0x9108, 0x9148, 0x9188 }
  628.        };
  629.  
  630. flavor svcfl[] = {
  631.     { DataAlt, 0, BYTE, scc, 0x58C0, 0x58C0, 0 }
  632.        };
  633.  
  634. flavor svsfl[] = {
  635.     { DataAlt, 0, BYTE, scc, 0x59C0, 0x59C0, 0 }
  636.        };
  637.  
  638. flavor swapfl[] = {
  639.     { DnDirect, 0, WORD, oneReg, 0, 0x4840, 0 }
  640.        };
  641.  
  642. flavor tasfl[] = {
  643.     { DataAlt, 0, BYTE, oneOp, 0x4AC0, 0x4AC0, 0 }
  644.        };
  645.  
  646. flavor trapfl[] = {
  647.     { Immediate, 0, 0, trap, 0, 0x4E40, 0 }
  648.        };
  649.  
  650. flavor trapvfl[] = {
  651.     { 0, 0, 0, zeroOp, 0, 0x4E76, 0 }
  652.        };
  653.  
  654. flavor tstfl[] = {
  655.     { DataAlt, 0, BWL, oneOp, 0x4A00, 0x4A40, 0x4A80 }
  656.        };
  657.  
  658. flavor unlkfl[] = {
  659.     { AnDirect, 0, 0, oneReg, 0, 0x4E58, 0 }
  660.        };
  661.  
  662.  
  663. /* Define a macro to compute the length of a flavor list */
  664.  
  665. #define flavorCount(flavorArray) (sizeof(flavorArray)/sizeof(flavor))
  666.  
  667.  
  668. /* The instruction table itself... */
  669.  
  670. instruction instTable[] = {
  671.     { "ABCD", abcdfl, flavorCount(abcdfl), TRUE, NULL },
  672.     { "ADD", addfl, flavorCount(addfl), TRUE, NULL },
  673.     { "ADDA", addafl, flavorCount(addafl), TRUE, NULL },
  674.     { "ADDI", addifl, flavorCount(addifl), TRUE, NULL },
  675.     { "ADDQ", addqfl, flavorCount(addqfl), TRUE, NULL },
  676.     { "ADDX", addxfl, flavorCount(addxfl), TRUE, NULL },
  677.     { "AND", andfl, flavorCount(andfl), TRUE, NULL },
  678.     { "ANDI", andifl, flavorCount(andifl), TRUE, NULL },
  679.     { "ASL", aslfl, flavorCount(aslfl), TRUE, NULL },
  680.     { "ASR", asrfl, flavorCount(asrfl), TRUE, NULL },
  681.     { "BCC", bccfl, flavorCount(bccfl), TRUE, NULL },
  682.     { "BCHG", bchgfl, flavorCount(bchgfl), TRUE, NULL },
  683.     { "BCLR", bclrfl, flavorCount(bclrfl), TRUE, NULL },
  684.     { "BCS", bcsfl, flavorCount(bcsfl), TRUE, NULL },
  685.     { "BEQ", beqfl, flavorCount(beqfl), TRUE, NULL },
  686.     { "BGE", bgefl, flavorCount(bgefl), TRUE, NULL },
  687.     { "BGT", bgtfl, flavorCount(bgtfl), TRUE, NULL },
  688.     { "BHI", bhifl, flavorCount(bhifl), TRUE, NULL },
  689.     { "BHS", bccfl, flavorCount(bccfl), TRUE, NULL },
  690.     { "BLE", blefl, flavorCount(blefl), TRUE, NULL },
  691.     { "BLO", bcsfl, flavorCount(bcsfl), TRUE, NULL },
  692.     { "BLS", blsfl, flavorCount(blsfl), TRUE, NULL },
  693.     { "BLT", bltfl, flavorCount(bltfl), TRUE, NULL },
  694.     { "BMI", bmifl, flavorCount(bmifl), TRUE, NULL },
  695.     { "BNE", bnefl, flavorCount(bnefl), TRUE, NULL },
  696.     { "BPL", bplfl, flavorCount(bplfl), TRUE, NULL },
  697.     { "BRA", brafl, flavorCount(brafl), TRUE, NULL },
  698.     { "BSET", bsetfl, flavorCount(bsetfl), TRUE, NULL },
  699.     { "BSR", bsrfl, flavorCount(bsrfl), TRUE, NULL },
  700.     { "BTST", btstfl, flavorCount(btstfl), TRUE, NULL },
  701.     { "BVC", bvcfl, flavorCount(bvcfl), TRUE, NULL },
  702.     { "BVS", bvsfl, flavorCount(bvsfl), TRUE, NULL },
  703.     { "CHK", chkfl, flavorCount(chkfl), TRUE, NULL },
  704.     { "CLR", clrfl, flavorCount(clrfl), TRUE, NULL },
  705.     { "CMP", cmpfl, flavorCount(cmpfl), TRUE, NULL },
  706.     { "CMPA", cmpafl, flavorCount(cmpafl), TRUE, NULL },
  707.     { "CMPI", cmpifl, flavorCount(cmpifl), TRUE, NULL },
  708.     { "CMPM", cmpmfl, flavorCount(cmpmfl), TRUE, NULL },
  709.     { "DBCC", dbccfl, flavorCount(dbccfl), TRUE, NULL },
  710.     { "DBCS", dbcsfl, flavorCount(dbcsfl), TRUE, NULL },
  711.     { "DBEQ", dbeqfl, flavorCount(dbeqfl), TRUE, NULL },
  712.     { "DBF", dbffl, flavorCount(dbffl), TRUE, NULL },
  713.     { "DBGE", dbgefl, flavorCount(dbgefl), TRUE, NULL },
  714.     { "DBGT", dbgtfl, flavorCount(dbgtfl), TRUE, NULL },
  715.     { "DBHI", dbhifl, flavorCount(dbhifl), TRUE, NULL },
  716.     { "DBHS", dbccfl, flavorCount(dbccfl), TRUE, NULL },
  717.     { "DBLE", dblefl, flavorCount(dblefl), TRUE, NULL },
  718.     { "DBLO", dbcsfl, flavorCount(dbcsfl), TRUE, NULL },
  719.     { "DBLS", dblsfl, flavorCount(dblsfl), TRUE, NULL },
  720.     { "DBLT", dbltfl, flavorCount(dbltfl), TRUE, NULL },
  721.     { "DBMI", dbmifl, flavorCount(dbmifl), TRUE, NULL },
  722.     { "DBNE", dbnefl, flavorCount(dbnefl), TRUE, NULL },
  723.     { "DBPL", dbplfl, flavorCount(dbplfl), TRUE, NULL },
  724.     { "DBRA", dbrafl, flavorCount(dbrafl), TRUE, NULL },
  725.     { "DBT", dbtfl, flavorCount(dbtfl), TRUE, NULL },
  726.     { "DBVC", dbvcfl, flavorCount(dbvcfl), TRUE, NULL },
  727.     { "DBVS", dbvsfl, flavorCount(dbvsfl), TRUE, NULL },
  728.     { "DC", NULL, 0, FALSE, dc },
  729.     { "DCB", NULL, 0, FALSE, dcb },
  730.     { "DIVS", divsfl, flavorCount(divsfl), TRUE, NULL },
  731.     { "DIVU", divufl, flavorCount(divufl), TRUE, NULL },
  732.     { "DS", NULL, 0, FALSE, ds },
  733.     { "END", NULL, 0, FALSE, funct_end },
  734.     { "EOR", eorfl, flavorCount(eorfl), TRUE, NULL },
  735.     { "EORI", eorifl, flavorCount(eorifl), TRUE, NULL },
  736.     { "EQU", NULL, 0, FALSE, equ },
  737.     { "EXG", exgfl, flavorCount(exgfl), TRUE, NULL },
  738.     { "EXT", extfl, flavorCount(extfl), TRUE, NULL },
  739.     { "ILLEGAL", illegalfl, flavorCount(illegalfl), TRUE, NULL },
  740.     { "JMP", jmpfl, flavorCount(jmpfl), TRUE, NULL },
  741.     { "JSR", jsrfl, flavorCount(jsrfl), TRUE, NULL },
  742.     { "LEA", leafl, flavorCount(leafl), TRUE, NULL },
  743.     { "LINK", linkfl, flavorCount(linkfl), TRUE, NULL },
  744.     { "LSL", lslfl, flavorCount(lslfl), TRUE, NULL },
  745.     { "LSR", lsrfl, flavorCount(lsrfl), TRUE, NULL },
  746.     { "MOVE", movefl, flavorCount(movefl), TRUE, NULL },
  747.     { "MOVEA", moveafl, flavorCount(moveafl), TRUE, NULL },
  748.     { "MOVEC", movecfl, flavorCount(movecfl), TRUE, NULL },
  749.     { "MOVEM", NULL, 0, FALSE, movem },
  750.     { "MOVEP", movepfl, flavorCount(movepfl), TRUE, NULL },
  751.     { "MOVEQ", moveqfl, flavorCount(moveqfl), TRUE, NULL },
  752.     { "MOVES", movesfl, flavorCount(movesfl), TRUE, NULL },
  753.     { "MULS", mulsfl, flavorCount(mulsfl), TRUE, NULL },
  754.     { "MULU", mulufl, flavorCount(mulufl), TRUE, NULL },
  755.     { "NBCD", nbcdfl, flavorCount(nbcdfl), TRUE, NULL },
  756.     { "NEG", negfl, flavorCount(negfl), TRUE, NULL },
  757.     { "NEGX", negxfl, flavorCount(negxfl), TRUE, NULL },
  758.     { "NOP", nopfl, flavorCount(nopfl), TRUE, NULL },
  759.     { "NOT", notfl, flavorCount(notfl), TRUE, NULL },
  760.     { "OR", orfl, flavorCount(orfl), TRUE, NULL },
  761.     { "ORG", NULL, 0, FALSE, org },
  762.     { "ORI", orifl, flavorCount(orifl), TRUE, NULL },
  763.     { "PEA", peafl, flavorCount(peafl), TRUE, NULL },
  764.     { "REG", NULL, 0, FALSE, reg },
  765.     { "RESET", resetfl, flavorCount(resetfl), TRUE, NULL },
  766.     { "ROL", rolfl, flavorCount(rolfl), TRUE, NULL },
  767.     { "ROR", rorfl, flavorCount(rorfl), TRUE, NULL },
  768.     { "ROXL", roxlfl, flavorCount(roxlfl), TRUE, NULL },
  769.     { "ROXR", roxrfl, flavorCount(roxrfl), TRUE, NULL },
  770.     { "RTD", rtdfl, flavorCount(rtdfl), TRUE, NULL },
  771.     { "RTE", rtefl, flavorCount(rtefl), TRUE, NULL },
  772.     { "RTR", rtrfl, flavorCount(rtrfl), TRUE, NULL },
  773.     { "RTS", rtsfl, flavorCount(rtsfl), TRUE, NULL },
  774.     { "SBCD", sbcdfl, flavorCount(sbcdfl), TRUE, NULL },
  775.     { "SCC", sccfl, flavorCount(sccfl), TRUE, NULL },
  776.     { "SCS", scsfl, flavorCount(scsfl), TRUE, NULL },
  777.     { "SEQ", seqfl, flavorCount(seqfl), TRUE, NULL },
  778.     { "SET", NULL, 0, FALSE, set },
  779.     { "SF", sffl, flavorCount(sffl), TRUE, NULL },
  780.     { "SGE", sgefl, flavorCount(sgefl), TRUE, NULL },
  781.     { "SGT", sgtfl, flavorCount(sgtfl), TRUE, NULL },
  782.     { "SHI", shifl, flavorCount(shifl), TRUE, NULL },
  783.     { "SHS", sccfl, flavorCount(sccfl), TRUE, NULL },
  784.     { "SLE", slefl, flavorCount(slefl), TRUE, NULL },
  785.     { "SLO", scsfl, flavorCount(scsfl), TRUE, NULL },
  786.     { "SLS", slsfl, flavorCount(slsfl), TRUE, NULL },
  787.     { "SLT", sltfl, flavorCount(sltfl), TRUE, NULL },
  788.     { "SMI", smifl, flavorCount(smifl), TRUE, NULL },
  789.     { "SNE", snefl, flavorCount(snefl), TRUE, NULL },
  790.     { "SPL", splfl, flavorCount(splfl), TRUE, NULL },
  791.     { "ST", stfl, flavorCount(stfl), TRUE, NULL },
  792.     { "STOP", stopfl, flavorCount(stopfl), TRUE, NULL },
  793.     { "SUB", subfl, flavorCount(subfl), TRUE, NULL },
  794.     { "SUBA", subafl, flavorCount(subafl), TRUE, NULL },
  795.     { "SUBI", subifl, flavorCount(subifl), TRUE, NULL },
  796.     { "SUBQ", subqfl, flavorCount(subqfl), TRUE, NULL },
  797.     { "SUBX", subxfl, flavorCount(subxfl), TRUE, NULL },
  798.     { "SVC", svcfl, flavorCount(svcfl), TRUE, NULL },
  799.     { "SVS", svsfl, flavorCount(svsfl), TRUE, NULL },
  800.     { "SWAP", swapfl, flavorCount(swapfl), TRUE, NULL },
  801.     { "TAS", tasfl, flavorCount(tasfl), TRUE, NULL },
  802.     { "TRAP", trapfl, flavorCount(trapfl), TRUE, NULL },
  803.     { "TRAPV", trapvfl, flavorCount(trapvfl), TRUE, NULL },
  804.     { "TST", tstfl, flavorCount(tstfl), TRUE, NULL },
  805.     { "UNLK", unlkfl, flavorCount(unlkfl), TRUE, NULL }
  806.        };
  807.  
  808.  
  809. /* Declare a global variable containing the size of the instruction table */
  810.  
  811. short int tableSize = sizeof(instTable)/sizeof(instruction);
  812.  
  813.